<p>This rule raises an issue when a ternary expression is used to select the minimum or maximum value between two operands, where the same logic can
be expressed more clearly using <code>Math.min()</code> or <code>Math.max()</code>.</p>
<h2>Why is this an issue?</h2>
<p>Ternary expressions that implement min/max logic can be harder to read and understand at first glance. When you see <code>height &gt; 50 ? 50 :
height</code>, you need to mentally parse the comparison logic to understand that it’s selecting the smaller value.</p>
<p>Using <code>Math.min(height, 50)</code> instead makes the intent immediately clear - you’re finding the minimum value. This semantic clarity
reduces cognitive load and makes the code more self-documenting.</p>
<p>Additionally, <code>Math.min()</code> and <code>Math.max()</code> functions:</p>
<ul>
  <li> Express intent more directly </li>
  <li> Are less prone to logical errors (no risk of swapping the wrong values in ternary branches) </li>
  <li> Provide consistency across the codebase </li>
  <li> Can easily handle more than two values if needed later </li>
</ul>
<p>The pattern recognition required to spot min/max logic in ternaries becomes unnecessary when using the appropriate Math functions, leading to more
maintainable code.</p>
<h3>What is the potential impact?</h3>
<p>This issue primarily affects code readability and maintainability. While it doesn’t introduce security vulnerabilities or runtime errors, it can
slow down development and code review processes as developers need extra time to understand the intent of ternary-based min/max logic.</p>
<h3>How to fix?</h3>
<p>Replace ternary expressions that select minimum values with <code>Math.min()</code>. When the ternary returns the smaller of two values, use
<code>Math.min()</code> instead.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const clampedHeight = height &gt; 50 ? 50 : height; // Noncompliant
const limitedWidth = width &gt;= 100 ? 100 : width; // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const clampedHeight = Math.min(height, 50);
const limitedWidth = Math.min(width, 100);
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-math-min-max.md">prefer-math-min-max</a> </li>
  <li> Math.min() - MDN - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min">Documentation for the
  Math.min() function</a> </li>
  <li> Math.max() - MDN - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max">Documentation for the
  Math.max() function</a> </li>
  <li> Conditional (ternary) operator - MDN - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator">Documentation for ternary operators and when
  to use them appropriately</a> </li>
</ul>
